package com.fxm.controller;

import com.fxm.client.SignClient;
import com.fxm.returns.RespEntity;
import com.fxm.returns.RespTable;
import com.fxm.vo.param.RewardParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 签到统计 前端控制器
 * </p>
 *
 * @author fxm
 * @since 2021-02-22
 */
@RestController
@RequestMapping("/sign")
@Slf4j
@Api(value = "签到总览", tags = "签到总览")
public class SignController {

    @Autowired
    private SignClient signClient;

    @GetMapping("/list")
    @ApiOperation(value = "签到总览列表")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "page", value = "当前页数", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "limit", value = "每页数量", required = true)
    })
    public RespTable ruleList(@RequestParam(value = "page", required = true) Integer page,
                              @RequestParam(value = "limit", required = true) Integer limit) {
        RespTable respTable = signClient.signList(page, limit);
        return respTable;
    }

    @GetMapping("/search")
    @ApiOperation(value = "搜索用户")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "page", value = "当前页数", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "limit", value = "每页数量", required = true),
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "username", value = "用户昵称", required = false)
    })
    public RespTable ruleSearch(@RequestParam(value = "page", required = true) Integer page,
                                @RequestParam(value = "limit", required = true) Integer limit,
                                @RequestParam(value = "username", required = false) String username) {
        RespTable respTable = signClient.searchSign(page, limit, username);
        return respTable;
    }

    @GetMapping("/reward")
    @ApiOperation(value = "签到奖励列表")
    public RespEntity rewardList() {
        RespEntity respEntity = signClient.rewardList();
        return respEntity;
    }

    @PutMapping("/update")
    @ApiOperation(value = "编辑签到奖励")
    public RespEntity rewardUpdate(RewardParam rewardParam) {
        RespEntity respEntity = signClient.rewardUpdate(rewardParam);
        return respEntity;
    }

}
